<template>
	<view class="">
		<view class="">
			<u-index-list :scrollTop="scrollTop" :index-list="indexList">
				<view v-for="(item, index) in list" :key="index">
					<u-index-anchor :index="item.letter" />
					<view @click="selectCarSeries(item1)" class="list-cell u-border-bottom" v-for="(item1, index1) in item.data" :key="index1">
						<image :src="https+item1.brandLogo" mode=""></image>
						{{item1.brandName}}
					</view>
				</view>
			</u-index-list>
		</view>
	</view>
</template>

<script>
	import API from "@/api/selectCar.js"
	import app from "../../App.vue"
	export default {
		name:"selectCar",
		onShow() {
			this.getBrandList();
		},
		data() {
			return {
				https: getApp().globalData.picturePath,
				scrollTop: 0,
				indexList: [],
				list: [],
				// carSeriesShow:false,
			}
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		methods:{
			getBrandList(){
				API.getBrandList().then(res=>{
					console.log(res);
					this.list = res.data;
					this.indexList = res.data.map(val => {
						return val.letter;
					})
				})
			},
			// 选择车系
			selectCarSeries(item) {
				app.globalData.carType = item
				uni.navigateBack({
					delta: 1
				})
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.list-cell {
		display: flex;
		box-sizing: border-box;
		width: 100%;
		padding: 10px 24rpx;
		overflow: hidden;
		color: $u-content-color;
		font-size: 14px;
		line-height: 24px;
		background-color: #fff;
		align-items: center;
		image{
			width: 60rpx;
			height: 60rpx;
			margin-right: 10rpx;
		}
	}
	
</style>
